#!/usr/bin/python

# Types
print type(type)

# Numbers: Interger, Decimal, Float, Complex
print 'Simple Integer: ', type(1), 12345
print 'Long Integer: ', type(2**9000), 2**1024
import math
print 'Float: ', type(1.2), math.sqrt(2)
import cmath
print 'Complex: ', type(1j), cmath.sqrt(-1)
import fractions
fr=fractions.Fraction(17)
fr/=13
print 'Fraction: ', type(fr), fr
import decimal
decimal.getcontext().prec=128
d=decimal.Decimal(1)
d/=3
print 'Decimal: ', type(d), d

# Strings
print type("str"), 'String', "String", "It's string", 'This is "string"'
print type('0'), '0',"0", chr(48), chr(0x30), ord('0'), ord("0"), ord('\x30')
print "\x41\x42\x43"
print "Hello" + chr(0x20) + 'World'
print "abc" * 4
print 'la' * 2 + "ka" * 2
print type(u'unicode string'), u"Unicode String"

# Lists
l=[0,"1",2,[3,"3",0+3j],4]
print type(l), l
l.append(5)
print l
l.append(l)
print l
l.append(100500)
print l
print l[0], l[1], l[2], l[3], l[4], l[5], l[6], l[7]
l=[1, 2, 3]
l.append(l)
print type(l), l
print l[3][3][3][3][3][3][3][3][3][3][3][3][3][3][3][3][3][3][3]

# Maps/Dictionaries
m = {'one':1, 'two':"2", "3":'3'}
print type(m), m
print 'm[\'one\']: ', m['one']
print 'm["two"]: ', m["two"]
print type(m['3']), m['3']
m[9000] = 100500
print m[9000]

# Tuples
t = ('x', 'y', 'z')
print type(t), t
print t[0], t[1], t[2]

# Files
f = open('basic_types.py')
print type(f), f

# Sets
s = {3,"2",(1,1)}
print type(s), s
print type(set('321')), set('54321')
s1 = set('54321')
s2 = {'6','5','4'}
print s1
print s2
print "s1|s2: ", s1|s2
print "s1&s2: ", s1&s2
print "s1-s2: ", s1-s2
print s1
s1.add('0')
print s1

# Boolean type
print type(1==1), 1==1, 1==2
b1=True
b2=False
print b1, b2
print not b1, not b2
print b1 and b2
print b1 or b2

# None type
print type(None), None

# Type's names
import types
print 'Logic type'
print types.BooleanType
print 'Number Types'
print types.IntType, types.LongType, types.FloatType, types.ComplexType
print 'Strings'
print types.StringType, types.UnicodeType, types.StringTypes
print 'Collections/Files'
print types.ListType, types.TupleType, types.DictionaryType, types.DictType, types.DictProxyType, types.FileType
print 'Other Types'
print types.NotImplementedType, types.BufferType, types.FrameType, types.ObjectType, types.BuiltinFunctionType
print types.FunctionType, types.BuiltinMethodType, types.GeneratorType, types.GetSetDescriptorType
print types.ClassType, types.CodeType, types.InstanceType, types.SliceType, types.LambdaType
print types.MemberDescriptorType, types.TracebackType, types.MethodType, types.EllipsisType, types.ModuleType
print types.TypeType, types.UnboundMethodType, types.NoneType, types.XRangeType

# Other Types
print type(math)
print type(math.sqrt)

